<table width="100%">
<tr>
  <td width="50%">
    <table width="100%">
      <tr align="center">
        <td width="20%"><a href="/user"><img src="/images/home_icon_small.png" border="0" style="vertical-align:middle;"/></a><br/>Home</td>
        <td width="20%"><a href="/game_runnings/gamepanel_a?gencode=<%=@gencode%>"><img src="/images/monitor_icon.png" border="0" style="vertical-align:middle;"/></a><br/>Panel A</td>
        <td width="20%"><a href="/game_runnings/gamepanel?gencode=<%=@gencode%>"><img src="/images/monitor_icon.png" border="0" style="vertical-align:middle;"/></a><br/>Panel B</td>
        <td width="20%"><a href="/game_runnings/summary?gencode=<%=@gencode%>"><img src="/images/summary_icon.jpg" border="0" style="vertical-align:middle;"/></a><br/>Summary</td>
        <td width="20%"><a href="/game_runnings/setting_parameter?gencode=<%=@gencode%>"><img src="/images/inventory_icon.jpg" border="0" style="vertical-align:middle;"/></a><br/>Setting</td>
      </tr>
    </table>
  </td>
  <td width="2%">&nbsp;</td>
  <td>
    <span style="background-color: green; width:350px; font-size: 2em; color:white; vertical-align:middle;">
    Year: <span id="yearpanel"><%=@game.current_year%></span>
    &nbsp;&nbsp;&nbsp;
    Round: <span id="roundpanel"><%=@game.current_round%></span>
    </span>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%if @game.run_flag=='N'%>
    <img src="/images/stop_icon.jpg" width="50px" style="vertical-align:middle;"/>
    <%else%>
    <img src="/images/start_icon.gif" width="50px" style="vertical-align:middle;"/>
    <%end%>
  </td>
</tr>
</table>
<h3>Setting Parameters</h3>
<center>
<font color="red">
  <%=@word%>
</font>
<br/>
</center>
<table width="100%">
<tr>
  <td valign="top" width="50%">
    <% form_for :game_setting, :url =>{ :action=>"set_parameter", :gencode=>@gencode} do |form| %>
    <table style="border: 1px solid black;">
    <tr>
      <td>ต้นทุนต่อหน่วย(ผลิตสินค้าตั้งต้น)</td><td><%=form.text_field :rawmat_unit_cost, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ต้นทุนต่อหน่วย(ตลาดสินค้าผู้บริโภค)<br/>(Market Maker)</td><td><%=form.text_field :unit_cost, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>เงินสดเริ่มต้น</td><td><%=form.text_field :start_cash, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>จำนวนหุ้นสามัญเริ่มต้น</td><td><%=form.text_field :start_common_stock_unit, :size=>15%> หุ้น</td>
    </tr>
    <tr>
      <td>Level0 Price Added</td><td><%=form.text_field :level0_price_added, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>Level1 Price Added</td><td><%=form.text_field :level1_price_added, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>Level2 Price Added</td><td><%=form.text_field :level2_price_added, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>Level3 Price Added</td><td><%=form.text_field :level3_price_added, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>Level4 Price Added</td><td><%=form.text_field :level4_price_added, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>จำนวนผลิตเพื่อเข้าสู่ Level1</td><td><%=form.text_field :level1_required_produce, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>จำนวนผลิตเพื่อเข้าสู่ Level2</td><td><%=form.text_field :level2_required_produce, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>จำนวนผลิตเพื่อเข้าสู่ Level3</td><td><%=form.text_field :level3_required_produce, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>จำนวนผลิตเพื่อเข้าสู่ Level4</td><td><%=form.text_field :level4_required_produce, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>ค่า Marketing เพื่อเข้าสู่ Level1</td><td><%=form.text_field :level1_required_marketing, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ค่า Marketing เพื่อเข้าสู่ Level2</td><td><%=form.text_field :level2_required_marketing, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ค่า Marketing เพื่อเข้าสู่ Level3</td><td><%=form.text_field :level3_required_marketing, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ค่า Marketing เพื่อเข้าสู่ Level4</td><td><%=form.text_field :level4_required_marketing, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>Minimum Common Stock</td><td><%=form.text_field :min_common_stock_unit, :size=>15%></td>
    </tr>
    <tr>
      <td>E2/E1 Limit</td><td><%=form.text_field :ee_limit, :size=>15%></td>
    </tr>
    <tr>
      <td>D/E Limit</td><td><%=form.text_field :de_limit, :size=>15%></td>
    </tr>
    <tr>
      <td>ราคา Factory</td><td><%=form.text_field :factory_price, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>อายุการใช้งาน Factory</td><td><%=form.text_field :factory_life, :size=>15%> ปี</td>
    </tr>
    <tr>
      <td>Factory Capacity</td><td><%=form.text_field :factory_capacity, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>ราคา Warehouse</td><td><%=form.text_field :warehouse_price, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>อายุการใช้งาน Warehouse</td><td><%=form.text_field :warehouse_life, :size=>15%> ปี</td>
    </tr>
    <tr>
      <td>Warehouse Capacity</td><td><%=form.text_field :warehouse_capacity, :size=>15%> หน่วย</td>
    </tr>
    <tr>
      <td>ปริมาณเงินกู้สูงสุด Level1</td><td><%=form.text_field :level1_debt_limit, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ปริมาณเงินกู้สูงสุด Level2</td><td><%=form.text_field :level2_debt_limit, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>ปริมาณเงินกู้สูงสุด Level3</td><td><%=form.text_field :level3_debt_limit, :size=>15%> บาท</td>
    </tr>
    <tr>
      <td>อายุ Logterm Debt</td><td><%=form.text_field :longterm_debt_life, :size=>15%> ปี</td>
    </tr>
    <tr>
      <td>อัตราดอกเบี้ยเงินกู้ Level1</td><td><%=form.text_field :level1_debt_rate, :size=>15%></td>
    </tr>
    <tr>
      <td>อัตราดอกเบี้ยเงินกู้ Level2</td><td><%=form.text_field :level2_debt_rate, :size=>15%></td>
    </tr>
    <tr>
      <td>อัตราดอกเบี้ยเงินกู้ Level3</td><td><%=form.text_field :level3_debt_rate, :size=>15%></td>
    </tr>
    <tr>
      <td>อัตราดอกเบี้ยเงินกู้ Level4</td><td><%=form.text_field :level4_debt_rate, :size=>15%></td>
    </tr>
    <tr>
      <td>อัตราดอกเบี้ยเงินกู้ฉุกเฉิน</td><td><%=form.text_field :emergency_debt_rate, :size=>15%></td>
    </tr>
    <tr>
      <td>อัตราภาษี</td><td><%=form.text_field :tax_rate, :size=>15%></td>
    </tr>
    <tr>
      <td></td><td><input type="submit" value="Save & Reset Game"/></td>
    </tr>
    </table>
    <%end%>
  </td>
  <td valign="top" align="center">
    <% form_for :game_setting, :url =>{ :action=>"set_bidask", :gencode=>@gencode} do |form| %>
    <table style="border: 1px solid black;" width="100%">
      <tr>
        <td>Min Sold</td><td><input type="text" name="min_sold" size="25" value="<%=@game.min_sold%>"/></td>
      </tr>
      <tr>
        <td>Max Sold</td><td><input type="text" name="max_sold" size="25" value="<%=@game.max_sold%>"/></td>
      </tr>
      <tr>
        <td>Use Step</td><td><%=form.text_field :step_flag, :size=>10%></td>
      </tr>
      <tr>
        <td>Total Step</td><td><%=form.text_field :total_step, :size=>10%></td>
      </tr>
      <tr>
        <td>Step Size</td><td><%=form.text_field :step_size, :size=>10%></td>
      </tr>
      <tr>
        <td>Price weight(Action weight)</td><td><%=form.text_field :price_weight, :size=>25%></td>
      </tr>
      <tr>
        <td>Factory(A) Name</td><td><%=form.text_field :factory_name_a, :size=>25%></td>
      </tr>
      <tr>
        <td>Warehouse(A) Name</td><td><%=form.text_field :warehouse_name_a, :size=>25%></td>
      </tr>
      <tr>
        <td>Factory(B) Name</td><td><%=form.text_field :factory_name, :size=>25%></td>
      </tr>
      <tr>
        <td>Warehouse(B) Name</td><td><%=form.text_field :warehouse_name, :size=>25%></td>
      </tr>
      <tr>
        <td>RawMat(A) Name</td><td><%=form.text_field :rawmat_a_name, :size=>25%></td>
      </tr>
      <tr>
        <td>Product(A) Name</td><td><%=form.text_field :inventory_a_name, :size=>25%></td>
      </tr>
      <tr>
        <td>Product(B) Name</td><td><%=form.text_field :inventory_b_name, :size=>25%></td>
      </tr>
      <tr>
        <td>(A)Rawmat Loss Rate</td><td><%=form.text_field :rawmat_loss_rate_a, :size=>10%></td>
      </tr>
      <tr>
        <td>(A)Inventory Loss Rate</td><td><%=form.text_field :inventory_loss_rate_a, :size=>10%></td>
      </tr>
      <tr>
        <td>(B)Rawmat Loss Rate</td><td><%=form.text_field :rawmat_loss_rate, :size=>10%></td>
      </tr>
      <tr>
        <td>(B)Inventory Loss Rate</td><td><%=form.text_field :inventory_loss_rate, :size=>10%></td>
      </tr>
      <tr>
        <td>Allow Put Option(A)</td><td><%=form.text_field :allow_put_option_a, :size=>10%></td>
      </tr>
      <!--tr>
        <td>Allow Put Option(B)</td><td><%=form.text_field :allow_put_option_b, :size=>10%></td>
      </tr-->
      <tr>
        <td>แสดงราคาเสนอขาย</td><td><%=form.text_field :show_ask_price, :size=>10%></td>
      </tr>
      <tr>
        <td>แสดง CreditTerm เสนอขาย</td><td><%=form.text_field :show_ask_credit_term, :size=>10%></td>
      </tr>
      <tr>
        <td>แสดงปริมาณเสนอขาย</td><td><%=form.text_field :show_ask_quantity, :size=>10%></td>
      </tr>
      <tr>
        <td>แสดงราคาเสนอซื้อ</td><td><%=form.text_field :show_bid_price, :size=>10%></td>
      </tr>
      <tr>
        <td>แสดง CreditTerm เสนอซื้อ</td><td><%=form.text_field :show_bid_credit_term, :size=>10%></td>
      </tr>
      <tr>
        <td>แสดงปริมาณเสนอซื้อ</td><td><%=form.text_field :show_bid_quantity, :size=>10%></td>
      </tr>
      <tr>
        <td>Direct Trade</td><td><%=form.text_field :direct_trade, :size=>10%></td>
      </tr>
      <tr>
        <td>Promotion</td><td><%=form.text_field :promotion, :size=>10%></td>
      </tr>
      <tr>
        <td>Value Chain</td><td><%=form.text_field :show_market, :size=>10%></td>
      </tr>
      <tr>
        <td>Buyer Futures</td><td><%=form.text_field :buyer_futures, :size=>10%></td>
      </tr>
      <tr>
        <td>Seller Futures</td><td><%=form.text_field :seller_futures, :size=>10%></td>
      </tr>
      <tr>
        <td>Position Limit(Net)</td><td><%=form.text_field :position_limit, :size=>10%></td>
      </tr>
      <tr>
        <td>Contract Size</td><td><%=form.text_field :contract_size, :size=>10%></td>
      </tr>
      <tr>
        <td>Initial Margin</td><td><%=form.text_field :initial_margin, :size=>10%></td>
      </tr>
      <tr>
        <td>Maintenance Margin</td><td><%=form.text_field :maintenance_margin, :size=>10%></td>
      </tr>
      <tr>
        <td>F(0,1) Price</td><td><%=form.text_field :f01_price, :size=>10%></td>
      </tr>
      <tr>
        <td>if damand/supply > ?<br/> => highprice</td><td><%=form.text_field :high_d2s, :size=>10%></td>
      </tr>
      <tr>
        <td>if demand/supply < ?<br/> => lowprice</td><td><%=form.text_field :low_d2s, :size=>10%></td>
      </tr>
      <tr>
        <td>LowPrice Range</td><td><%=form.text_field :min_lowrange, :size=>5%> - <%=form.text_field :max_lowrange, :size=>5%></td>
      </tr>
      <tr>
        <td>MidPrice Range</td><td><%=form.text_field :min_midrange, :size=>5%> - <%=form.text_field :max_midrange, :size=>5%></td>
      </tr>
      <tr>
        <td>HighPrice Range</td><td><%=form.text_field :min_highrange, :size=>5%> - <%=form.text_field :max_highrange, :size=>5%></td>
      </tr>
      <tr>
        <td>Rational Random</td><td><%=form.text_field :rational_random, :size=>10%></td>
      </tr>
      <tr>
        <td></td><td><input type="submit" value="Save"/></td>
      </tr>
    </table>
    <%end%>
    <br/>
    <form action="/game_runnings/set_error?gencode=<%=@gencode%>" method="post">
    <table style="border: 1px solid black;">
      <tr align="center" style="font-size:15px;">
        <th style="border: 1px solid black;" rowspan="2">Year</th>
        <th style="border: 1px solid black;" rowspan="2">Min<br/>Error</th>
        <th style="border: 1px solid black;" rowspan="2">Max<br/>Error</th>
        <th style="border: 1px solid black;" rowspan="2">Min<br/>Price</th>
        <th style="border: 1px solid black;" rowspan="2">Max<br/>Price</th>
        <th rowspan="2">&nbsp;&nbsp;&nbsp;</th>
        <th style="border: 1px solid black;" colspan="2">Put Option(A)</th>
        <!--th style="border: 1px solid black;" colspan="2">Put Option(B)</th-->
        <th style="border: 1px solid black;" rowspan="2">Next-Year<br/>Inflation</th>
      </tr>
      <tr align="center" style="font-size:15px">
        <th style="border: 1px solid black;">Price</th>
        <th style="border: 1px solid black;">Ex.Price</th>
        <!--th style="border: 1px solid black;">Price</th>
        <th style="border: 1px solid black;">Ex.Price</th-->
      </tr>
      <%@game_errors.each do |ge|%>
      <tr align="center">
        <td><%=ge.year%></td>
        <td><input type="text" name="min_error_<%=ge.year%>" style="width:35px;" value="<%=ge.min_error%>"/></td>
        <td><input type="text" name="max_error_<%=ge.year%>" style="width:35px;" value="<%=ge.max_error%>"/></td>
        <td><input type="text" name="min_price_<%=ge.year%>" style="width:35px;" value="<%=ge.min_price%>"/></td>
        <td><input type="text" name="max_price_<%=ge.year%>" style="width:35px;" value="<%=ge.max_price%>"/></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td><input type="text" name="put_price_a_<%=ge.year%>" style="width:35px;" value="<%=ge.put_price_a%>"/></td>
        <td><input type="text" name="put_exprice_a_<%=ge.year%>" style="width:35px;" value="<%=ge.put_exprice_a%>"/></td>
        <!--td><input type="text" name="put_price_b_<%#=ge.year%>" style="width:35px;" value="<%#=ge.put_price_b%>"/></td>
        <td><input type="text" name="put_exprice_b_<%#=ge.year%>" style="width:35px;" value="<%#=ge.put_exprice_b%>"/></td-->
        <td><input type="text" name="inflation_<%=ge.year%>" style="width:35px;" value="<%=ge.inflation%>"/></td>
      </tr>
      <%end%>
      <tr>
        <td colspan="5" align="center"><input type="submit" value="Save"/></td>
      </tr>
    </table>
    </form>
  </td>
</tr>
</table>